#! /usr/bin/env bash

thedir=$1
hemisphere=$2

env_str='source activate ATL14;'
#env_str=''

prog='/home/besmith4/git_repos/pointCollection/pointCollection/index_glob.py'
#prog='/home/ben/git_repos/pointCollection/pointCollection/index_glob.py'

[ -d $thedir/index ] || mkdir $thedir/index

> index_queue.txt

for file in `ls $thedir/ATL11_??????_????_???_??.h5`; do 
    out_file=$thedir"/index/"`basename $file`
    [ -f $out_file ] && continue
    echo "$env_str python3 $prog  --hemisphere $hemisphere --type ATL11 -g $file --index_file $out_file --dir_root $thedir" >> index_queue.txt
done 

pboss.py -s index_queue.txt -r -w -j 8

source activate ATL14; python3 $prog --type h5_geoindex -g "$thedir/index/ATL11*.h5" --index_file $thedir/index/GeoIndex.h5 --dir_root $thedir/index/ --hemisphere $hemisphere

